package com.chebaohui.iqs.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.chebaohui.iqs.config.ResultCode;
import com.chebaohui.iqs.entity.Paramter;
import com.chebaohui.iqs.entity.Result;
import com.chebaohui.iqs.entity.base.Message;
import com.chebaohui.iqs.service.MessageService;
import com.chebaohui.iqs.sign.SignParam;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

/**
 * describe:控制层:短信
 * 
 * @author regas_xie
 *
 */
@Api(value = "message", description = "短信发送接口", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@RestController
@RequestMapping(value = "message")
public class MessageController {

	@Autowired
	private MessageService message;

	@ApiOperation(value = "短信发送", httpMethod = "POST", notes = "银短信发送,返回是否发送成功")
	@RequestMapping(value = "/send", method = RequestMethod.POST)
	public Result<Object> sendMessage(
			@ApiParam(value = "短信发送请求参数", required = true) @RequestBody(required = false) Paramter<Message> param) {
		if (!SignParam.decrypted(param.getSign()))
			return new Result<>(ResultCode.L01);

		return message.send(param);
	}
}
